export default {
  addCounter(state, payload) {
    payload.count += 1
  },
  addToCart(state, payload) {
    // 当一个商品加入到购物车的时候，默认将它选中
    payload.checked = true
    state.cartList.push(payload)
  },
  addToOrder(state, payload) {
    state.orderList.push(...payload)
  },
  addOrder(state, payload) {
    // localStorage.push('orderitem',payload)
    state.orderList.push(payload)
  },
  // addusrInfo(state,payload){
  //   state.usrInfo = []
  //   state.usrInfo.push(payload)
  // },
  deleteorder(state,payload) {
    state.orderList = []
  },
  setusrInfo(state, v){
    localStorage.setItem('usrInfo', JSON.stringify(v));
    state.usr = v
  },
  handleDelete(state) {
    state.cartList.forEach((itemA, indexA) => {
        state.orderList.forEach(itemB => {
            if (itemA === itemB) {
              state.cartList.splice(indexA, 1, "删我")
            }
        })
    })
    state.cartList = state.cartList.filter(item => item !== "删我")
  },
  loginchecked(state,payload) {
    state.islogin = payload
  }
}